#!/bin/sh
#
# /etc/rc.d/rc.openvassd
#
# Start/stop/restart/reload the OpenVAS Scanner Daemon.
#
# To make OpenVAS Scanner start automatically at boot, make this
# file executable:  chmod 755 /etc/rc.d/rc.openvassd
# and add to rc.local:
# if [ -x /etc/rc.d/rc.openvassd ]; then
#   . /etc/rc.d/rc.openvassd start
# fi
#

OPENVASSD_PATH=/usr/sbin
OPENVASSD_BIN=openvassd
OPENVASSD_OPTIONS="-a 127.0.0.1 --gnutls-priorities=SECURE128:-VERS-SSL3.0"
OPENVASSD_CMD="$OPENVASSD_PATH/$OPENVASSD_BIN $OPENVASSD_OPTIONS"

openvassd_start() {
  echo Starting OpenVAS Scanner: $OPENVASSD_CMD
  $OPENVASSD_CMD
}

openvassd_stop() {
  echo "Stopping OpenVAS Scanner"
  /bin/killall $OPENVASSD_BIN
}

openvassd_restart() {
  openvassd_stop
  sleep 2
  openvassd_start
}

openvassd_reload() {
  /bin/killall -HUP $OPENVASSD_BIN
}

case "$1" in
'start')
  openvassd_start
  ;;
'stop')
  openvassd_stop
  ;;
'restart')
  openvassd_restart
  ;;
'reload')
  openvassd_reload
  ;;
*)
  echo "usage $0 start|stop|restart|reload"
esac
